# coding: UTF-8
'''
Created on 2011-5-7

@author: yang_wanjun
'''
from django import forms
from django.contrib.auth.models import User
from django.utils.translation import gettext_lazy as _
from senbzblog.blog import models as blogmodels

class BlogForm(forms.ModelForm):
    class Meta:
        model = blogmodels.BlogInfo
        fields = ('title', 'description', 'notice', 'theme', 'display_count', 'allow_comment')
        widgets = {'description':forms.Textarea(attrs={'rows':5}),
                   'notice':forms.Textarea(attrs={'rows':5}),
                   }

class UserChangeForm(forms.ModelForm):
    username = forms.CharField(max_length=30, label=_('username'), widget=forms.TextInput(attrs={'readonly': 'readonly'}), help_text=_("you can't change your username."))
    class Meta:
        model = User
        fields = ('username', 'first_name', 'last_name', 'email')

class ProfileForm(forms.ModelForm):
    class Meta:
        model = blogmodels.UserProfile
        widgets = {'description':forms.Textarea(attrs={'rows':5}), }

class LinkForm(forms.ModelForm):
    id = forms.IntegerField(required=False, widget=forms.HiddenInput())
    class Meta:
        model = blogmodels.Link
        widgets = {'description':forms.Textarea(attrs={'rows':5, 'style':'width:99%;'}), }
        
class CategoryForm(forms.ModelForm):
    class Meta:
        model = blogmodels.Category
        widgets = {'id':forms.HiddenInput(),
                   'blog':forms.HiddenInput(),
                   'type': forms.HiddenInput(),
                   'order': forms.HiddenInput(),
                   'description':forms.Textarea(attrs={'rows':5, 'style':'width:99%;'}),
                   }

class ArticleForm(forms.ModelForm):
    class Meta:
        model = blogmodels.Article
        widgets = {'id': forms.HiddenInput(),
                   'contents': forms.Textarea(attrs={'rows':15, 'style': 'width:99%;'}),
                   'summary': forms.Textarea(attrs={'rows':5, 'style': 'width:99%;'}),
                   'blog':forms.HiddenInput(),
                   'is_published':forms.HiddenInput(),
                   'category':forms.Select(attrs={'style':'width:100%;', 'size':'8'}),
                   }
        
class PageForm(forms.ModelForm):
    class Meta:
        model = blogmodels.Page
        widgets = {'id': forms.HiddenInput(),
                   'order': forms.HiddenInput(),
                   'contents': forms.Textarea(attrs={'rows':15, 'style': 'width:99%;'}),
                   'blog':forms.HiddenInput(),
                   'is_published':forms.HiddenInput(),
                   }
